import numpy as np
import matplotlib.pyplot as plt

def geometric_brownian_motion(S0=200, mu=0.05, sigma=0.2, T=1, dt=0.01):
    N = round(T/dt)
    t = np.linspace(0, T, N)
    W = np.random.standard_normal(size=N)
    W = np.cumsum(W)*np.sqrt(dt) # 标准布朗运动
    X = (mu - 0.5*sigma**2)*t + sigma*W 
    S = S0*np.exp(X) # 几何布朗运动
    
    plt.figure(figsize=(10,6))
    plt.plot(t, S)
    plt.title('Geometric Brownian Motion')
    plt.xlabel('Time')
    plt.ylabel('Price')
    plt.show()

geometric_brownian_motion()

